<template>
  <div class="box">
    <p>*可通过在职状态、操作端及账号状态控制员工是否可以登录对应的端及平台</p>
    <p>-基本信息</p>
    <el-form
      ref="formInline"
      :model="formInline"
      class="demo-form-inline"
      label-width="100px"
      status-icon
      :rules="rules"
      size="small"
    >
      <el-row>
        <el-col :span="12">
          <el-form-item label="工号" prop="jobNumber">
            <el-input
              v-model="formInline.jobNumber"
              placeholder="工号"
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="员工姓名" prop="employeeName">
            <el-input
              v-model="formInline.employeeName"
              placeholder="员工姓名"
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="身份证号" prop="cardNumber">
            <el-input
              v-model="formInline.cardNumber"
              placeholder="身份证号"
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="手机号" prop="phoneNumber">
            <el-input
              v-model="formInline.phoneNumber"
              placeholder="手机号"
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="邮箱" prop="email">
            <el-input v-model="formInline.email" placeholder="邮箱"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="所属公司" prop="firmId">
            <el-select
              v-model="formInline.firmId"
              placeholder="所属公司"
              @change="showDept"
            >
              <el-option
                v-for="item in firmId"
                :key="item.id"
                :label="item.companyName"
                :value="item.id"
              ></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="一级归类">
            <el-select
              v-model="formInline.agentType"
              placeholder="一级归类"
              @change="showArea"
            >
              <el-option
                v-for="item in agentType"
                :key="item.itemValue"
                :label="item.itemText"
                :value="item.itemValue"
              ></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="二级归类">
            <el-select v-model="formInline.classify" placeholder="二级归类">
              <el-option
                v-for="item in description"
                :key="item.itemValue"
                :label="item.itemText"
                :value="item.itemValue"
              ></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item prop="deptId" label="部门">
            <treeselect
              :options="deptData"
              :clearable="false"
              class="treeSelect"
              v-model="formInline.deptId"
              :normalizer="normalizer"
              @select="selectDepart"
              placeholder="请选择"
              style="width: 240px"
            />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="在职状态" prop="postStatus">
            <el-select v-model="formInline.postStatus" placeholder="在职状态">
              <el-option
                v-for="item in newjobState"
                :key="item.id"
                :label="item.itemText"
                :value="item.id"
              ></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="员工类型" prop="empClass">
            <el-select
              v-model="formInline.empClass"
              @change="changeEmpClass"
              placeholder="员工类型"
            >
              <el-option
                v-for="item in newemployee"
                :key="item.id"
                :label="item.itemText"
                :value="item.id"
              ></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="12" v-if="empShow">
          <el-form-item label="是否合伙人" prop="teamPartnerStatus">
            <el-radio-group v-model="formInline.teamPartnerStatus" size="small">
              <el-radio
                v-for="item in spreadStatus"
                :key="item.id"
                :label="item.itemValue"
                >{{ item.itemText }}</el-radio
              >
            </el-radio-group>
            <el-button type="text" v-if="teamPartner" @click="removePartner"
              >解散</el-button
            >
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="上级合伙人" prop="partnerName">
            <el-input
              v-model="formInline.partnerName"
              placeholder="上级合伙人"
              disabled
            ></el-input>
            <el-button type="text" @click="removePartner">清除</el-button>
          </el-form-item>
        </el-col>
        <el-col
          :span="24"
          style="
            background-color: rgba(242, 242, 242, 1);
            padding: 10px 0;
            margin-bottom: 10px;
          "
          v-if="empShow"
        >
          <el-col :span="12">
            <el-form-item label="合伙人等级" prop="partnerGrade">
              <el-select
                v-model="formInline.partnerGrade"
                placeholder="合伙人等级"
                :clearable="true"
                :disabled="isPartner"
              >
                <el-option
                  v-for="item in partnerGrade"
                  :key="item.id"
                  :label="item.itemText"
                  :value="item.itemValue"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <span class="text"> 上年收入￥25452.24</span>
          </el-col>
          <el-col :span="24"
            ><span class="text ts"
              >年50万进件为一级，50-200为二级，200以上为三级</span
            ></el-col
          >
        </el-col>
        <el-col :span="12">
          <el-form-item label="开户银行" prop="depositBank">
            <el-input
              v-model="formInline.depositBank"
              placeholder="开户银行"
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="银行卡号" prop="bankCard">
            <el-input
              v-model="formInline.bankCard"
              placeholder="银行卡号"
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="操作端">
            <el-checkbox v-model="bigDataStatus" @change="bigStatus"
              >大数据系统</el-checkbox
            >
            <el-checkbox v-model="miniApp" @change="appStatus"
              >经纪人小程序</el-checkbox
            >
            <el-checkbox v-model="recordMiniApp" @change="minAppStatus"
              >录单小程序</el-checkbox
            >
            <el-checkbox v-model="channelStatus" @change="channelPcStatus"
              >渠道录件系统</el-checkbox
            >
            <el-checkbox v-model="evaluateStatus" @change="evaluateStatusButton"
              >勘测评估系统</el-checkbox
            >
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="账号状态" prop="idStatus">
            <el-select v-model="formInline.idStatus" placeholder="账号状态">
              <el-option
                v-for="item in newastatus"
                :key="item.id"
                :label="item.itemText"
                :value="item.id"
              ></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="职级" prop="position">
            <el-select
              v-model="formInline.positionGrade"
              placeholder="员工职级"
            >
              <el-option
                v-for="item in newrank"
                :key="item.id"
                :label="item.positionName"
                :value="item.id"
              ></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="24" class="ts">
          <el-col :span="8">
            <el-form-item label="渠道管理" prop="trenchType">
              <el-select
                v-model="formInline.trenchType"
                @change="changeTrech"
                placeholder="渠道管理"
              >
                <el-option
                  v-for="item in trenchStatus"
                  :key="item.id"
                  :label="item.itemText"
                  :value="item.itemValue"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="渠道人员">
              <el-select
                v-model="formInline.trenchPersonnel"
                filterable
                remote
                reserve-keyword
                :disabled="disabled"
                @change="changeTrenchPersonnel"
                placeholder="请输入渠道人员"
                :remote-method="remoteMethod"
                :loading="loading"
              >
                <el-option
                  v-for="item in options"
                  :key="item.id"
                  :label="item.value"
                  :value="item.id"
                >
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8" class="flex">
            <el-form-item label="提成时长" prop="cutLength">
              <el-input
                v-model="formInline.cutLength"
                placeholder="提成时长"
              ></el-input>
              月
            </el-form-item>
          </el-col>
        </el-col>
        <el-col :span="12">
          <el-form-item label="员工归类" prop="classify">
            <el-select v-model="formInline.classify" placeholder="员工归类">
              <el-option
                v-for="item in ificaList"
                :key="item.itemValue"
                :label="item.itemText"
                :value="item.itemValue"
              ></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="登录密码" prop="loginPass">
            <el-input
              v-model="formInline.loginPass"
              placeholder="登录密码"
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="9">
          <el-form-item label="授权密码">
            <el-input
              v-model="formInline.authorityPass"
              placeholder="授权密码"
              :disabled="inputDisable"
              style="width: 180px"
            ></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="3">
          <el-button type="small" @click="shengcheng" v-if="!this.newadd"
            >生成</el-button
          >
        </el-col>
        <el-col :span="24">
          <el-form-item label="是否投放" prop="putStatus">
            <el-radio-group v-model="formInline.putStatus" size="small">
              <el-radio
                v-for="item in spreadStatus"
                :key="item.id"
                :label="item.itemValue"
                >{{ item.itemText }}</el-radio
              >
            </el-radio-group>
          </el-form-item>
        </el-col>
      </el-row>
      <p v-if="tbEmployeeUpdateRoleBtn">-角色权限</p>
      <el-form-item v-if="tbEmployeeUpdateRoleBtn">
        <el-checkbox-group v-model="checkData">
          <el-checkbox
            v-for="item in roleList"
            :key="item.id"
            :label="item.id"
            >{{ item.roleName }}</el-checkbox
          >
        </el-checkbox-group>
      </el-form-item>
    </el-form>
    <span slot="footer" class="dialog-footer">
      <el-button @click="closeDialog">取 消</el-button>
      <el-button type="primary" @click="subDialog"> 提 交 </el-button>
    </span>
  </div>
</template>

<script>
import {
  getCompanyList,
  saveCompanyEmploy,
  updateCompanyEmploy,
  getGradeList,
  getDepartment,
  getRoleList,
  departAdd,
  getEmployee,
  getOneEmploy,
  getTbEmplBy,
  getEmployeesClassified,
  getTwoClassified,
} from "../../../src/assets/js/api";
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
import { checkPermiss } from "../../assets/js/utlis";

export default {
  name: "Employ",
  components: { Treeselect },
  props: {
    newjobState: {
      type: Array,
    },
    newemployee: {
      type: Array,
    },
    newrank: {
      type: Array,
    },
    newastatus: {
      type: Array,
    },
    partnerStatus: {
      type: Array,
    },
    spreadStatus: {
      type: Array,
    },
    newadd: {
      type: Boolean,
    },
    tableInform: {
      type: Object,
    },
    gradeData: {
      type: Object,
    },
    dialogVisible: {
      type: Boolean,
      required: true,
    },
  },
  data() {
    return {
      empShow: false,
      deptData: [],
      normalizer(node) {
        //去掉children=[]的children属性
        if (node.children == null) {
          delete node.children;
        }
      },
      bigDataStatus: false,
      options: [],
      restaurants: [],
      loading: false,
      timeout: null,
      miniApp: false,
      recordMiniApp: false,
      channelStatus: false, //渠道录件系统!
      evaluateStatus: false, //勘测评估系统!
      gradeDataList: [],
      formInline: {
        id: "",
        authorityPass: "",
        bigDataStatus: "",
        cardNumber: "",
        phoneNumber: "",
        deptId: null,
        email: "",
        empClass: "",
        employeeName: "",
        agentType: [], //一级归类!
        description: [], //二级归类!
        firmId: "", //所属公司!
        idStatus: "",
        jobNumber: "",
        loginPass: "",
        postStatus: "",
        miniApp: "",
        recordMiniApp: "",
        channelStatus: "", //渠道录件系统
        evaluateStatus: "", //勘测评估系统!
        roleIds: [],
        classify: "",
        teamPartnerStatus: "0",
        superiorPartner: "",
        partnerName: "",
        partnerGrade: "",
        depositBank: "",
        bankCard: "",
        trenchType: "",
        trenchPersonnel: null,
        putStatus: "0",
        cutLength: null,
      },
      bus: {
        trenchPersonnel: null,
      },
      partnerGrade: [],
      checkData: [],
      inputDisable: false,
      gradeList: [],
      deptDataList: [],
      position: [],
      agentType: [], //一级归类!
      description: [], //二级归类!
      result: "",
      roleList: [],
      ificaList: [],
      trenchStatus: [],
      jobState: [
        { value: "0", label: "不限" },
        { value: "1", label: "在职" },
        { value: "2", label: "离职" },
      ],
      firmId: [
        { id: "0", companyName: "" },
        { id: "1", companyName: "重庆德创" },
      ],
      rules: {
        employeeName: [
          // required: 非空规则
          // message: 提示信息
          // trigger: 触发的方式  blur  change
          { required: true, message: "请输入用户名", trigger: "change" },
          {
            min: 2,
            max: 12,
            message: "长度在 2 到 12 个字符",
            trigger: "change",
          },
        ],
        // jobNumber: [
        //   { required: true, message: "请填写员工工号", trigger: "chang" },
        //   {
        //     min: 3,
        //     max: 12,
        //     message: "长度在 3 到 12 个字符",
        //     trigger: "change"
        //   }
        // ],
        firmId: [{ required: true, message: "请选择部门", trigger: "change" }],
        prop: [{ required: true, message: "请选择部门", trigger: "change" }],

        empClass: [
          { required: true, message: "请选择类型", trigger: "change" },
        ],
        deptId: [{ required: true, message: "请选择部门", trigger: "change" }],
        cardNumber: [
          { required: false, message: "请填写证件号码", trigger: "blur" },
          {
            pattern:
              /(^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$)|(^[1-9]\d{5}\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{2}$)/,
            message: "证件号码格式有误！",
            trigger: "blur",
          },
        ],
        phoneNumber: [
          { required: true, message: "请输入手机号码", trigger: "change" },
          {
            validator: function (rule, value, callback) {
              if (/^1[345789]\d{9}$/.test(value) == false) {
                callback(new Error("手机号格式错误"));
              } else {
                callback();
              }
            },
            trigger: "blur",
          },
        ],
        // email: [
        //   {
        //     required: true,
        //     message: "请输入邮箱",
        //     trigger: "blur"
        //   },
        //   {
        //     validator: function(rule, value, callback) {
        //       if (
        //         /^\w{1,64}@[a-z0-9-]{1,256}(\.[a-z]{2,6}){1,2}$/i.test(value) ==
        //         false
        //       ) {
        //         callback(new Error("邮箱格式错误"));
        //       } else {
        //         callback();
        //       }
        //     },
        //     trigger: "blur"
        //   }
        // ]
      },
    };
  },
  created() {
    this.getEmployeesClassified(); //一级归类!
    // this.getTwoClassified()//二级归类!
    this.golbalPermissions = localStorage.getItem("permissions").split(",");
    this.inputDisable = true;
    // if (this.newadd == true) {
    //   this.inputDisable = true;
    // }
    if (this.newadd == true) {
      this.empShow = false;
    } else {
      if (this.tableInform.empClass == 1) {
        this.empShow = true;
      } else {
        this.empShow = false;
      }
    }
    this.getRoleList();
    this.classification();
  },
  computed: {
    // 设置角色
    tbEmployeeUpdateRoleBtn: function () {
      return checkPermiss("sys:tbEmployee:updateRole", this.golbalPermissions);
    },
    teamPartner: function () {
      if (this.formInline.teamPartnerStatus == 1) {
        return true;
      } else {
        return false;
      }
    },
    isPartner: function () {
      if (this.formInline.teamPartnerStatus == 0) {
        return true;
      } else {
        return false;
      }
    },
    disabled: function () {
      if (this.formInline.trenchType == 0) {
        return true;
      } else {
        return false;
      }
    },
  },
  methods: {
    //获取一级归类!
    getEmployeesClassified() {
      getEmployeesClassified().then((res) => {
        this.agentType = res.data;

        this.agentType = this.agentType.map((item) => {
          return { ...item, itemValue: Number(item.itemValue) };
        });
        // console.log('qweqwqeqe', this.agentType)
      });
    },
    //获取二级归类!
    getTwoClassified() {
      getTwoClassified();
    },

    changeTrenchPersonnel() {
      this.bus.trenchPersonnel = this.formInline.trenchPersonnel;
    },
    //渠道人员修改
    changeTrech() {
      this.formInline.trenchPersonnel = null;
      this.bus.trenchPersonnel = null;
    },
    //获取部门
    getDepartAdd(id) {
      departAdd(id).then((res) => {
        this.deptData = res.data;
      });
    },
    getTableInform() {
      if (!this.newadd) {
        let thisObj = this;
        getOneEmploy(this.tableInform.id).then((res) => {
          var levelItem = this.agentType.find((item) => {
            return item.itemValue == res.data.agentType;
          });

          //   this.levelItem = this.agentType.find(item => item.id == res.data.agentType);
          //   levelItem.description = null;
          if (levelItem.description) {
            getTwoClassified(levelItem.description).then((res) => {
              this.description = res.data;

              this.description = this.description.map((item) => {
                return { ...item, itemValue: Number(item.itemValue) };
              });
            });
          }

          thisObj.formInline = res.data;
          this.bus.trenchPersonnel = this.formInline.trenchPersonnel;
          this.formInline.trenchPersonnel = this.formInline.trenchName;
          thisObj.getDepartAdd(thisObj.tableInform.firmId);
          thisObj.checkData = thisObj.formInline.roleIds;

          thisObj.formInline.authorityPass = "";
          thisObj.formInline.loginPass = "";
          thisObj.formInline.putStatus = String(thisObj.formInline.putStatus);
          thisObj.formInline.teamPartnerStatus = String(
            thisObj.formInline.teamPartnerStatus
          );
          thisObj.deptDataList = thisObj.deptData;

          if (thisObj.tableInform.bigDataStatus === 1) {
            thisObj.bigDataStatus = true;
          } else {
            thisObj.bigDataStatus = false;
          }

          if (thisObj.tableInform.miniApp === 1) {
            thisObj.miniApp = true;
          } else {
            thisObj.miniApp = false;
          }

          if (thisObj.tableInform.recordMiniApp === 1) {
            thisObj.recordMiniApp = true;
          } else {
            thisObj.recordMiniApp = false;
          }
          if (thisObj.tableInform.channelStatus === 1) {
            thisObj.channelStatus = true;
          } else {
            thisObj.channelStatus = false;
          }
          if (thisObj.tableInform.evaluateStatus === 1) {
            this.evaluateStatus = true;
          } else {
            this.evaluateStatus = false;
          }
        });
      }
    },
    //模糊查询渠道人员
    remoteMethod(query) {
      if (query !== "") {
        this.loading = true;
        getTbEmplBy({ name: query }).then((res) => {
          //this.restaurants = res.data;
          setTimeout(() => {
            this.loading = false;
            this.options = res.data;
          }, 200);
        });
      } else {
        this.options = [];
      }
    },
    querySearchAsync(queryString, cb) {
      var restaurants = this.restaurants;
      var results = queryString
        ? restaurants.filter(this.createStateFilter(queryString))
        : restaurants;
      clearTimeout(this.timeout);
      this.timeout = setTimeout(() => {
        cb(results);
      }, 3000 * Math.random());
    },
    createStateFilter(queryString) {
      return (state) => {
        return (
          state.value.toLowerCase().indexOf(queryString.toLowerCase()) === 0
        );
      };
    },
    // handleSelect(item) {
    //   console.log(item);
    // },
    // 查询角色
    getRoleList() {
      getRoleList().then((res) => {
        this.roleList = res.data;
      });
    },
    // 查询数据字典
    classification() {
      //获取员工管理
      getEmployee("classification").then((res) => {
        this.ificaList = res.data;
        this.ificaList.map((item) => {
          item.itemValue = Number(item.itemValue);
        });
      });
      //合伙人等级
      getEmployee("partner_grade").then((res) => {
        this.partnerGrade = res.data;
        this.partnerGrade.map((item) => {
          item.itemValue = Number(item.itemValue);
        });
      });
      getEmployee("trench_status").then((res) => {
        this.trenchStatus = res.data;
        this.trenchStatus.map((item) => {
          item.itemValue = Number(item.itemValue);
        });
      });
    },
    //随机生成一个8位数验证密码
    GetRandomNumber() {
      // let isNew = this.newadd;
      // if (isNew) {
      let number = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0];
      let letter = ["a", "b", "c", "d", "e", "f", "g", "h", "j", "k"];
      let result = "";
      let letterSum = "";
      let numberSum = "";
      for (var i = 0; i < 4; i++) {
        var count = parseInt(Math.random() * 10);
        letterSum += letter[count];
        numberSum += number[count];
        result = letterSum + numberSum;
      }
      this.formInline.authorityPass = result;
      // }
    },
    shengcheng() {
      this.GetRandomNumber();
    },
    //获取公司列表
    getCompanyList() {
      getCompanyList().then((res) => {
        this.firmId = res.data;
      });
    },
    // 获取职级
    getGradeList() {
      getGradeList().then((res) => {
        this.position = res.data;
      });
    },
    // 根据公司获取部门
    showDept(item) {
      getDepartment(item).then((res) => {
        this.deptData = res.data;
        this.formInline.deptId = null;
      });
    },
    // 获取选择的员工类型
    changeEmpClass(obj) {
      if (obj == 1) {
        this.empShow = true;
      } else {
        this.empShow = false;
      }
    },
    //一级分类点击事件!
    showArea(row) {
      let val = this.agentType.find((item) => {
        return item.itemValue == row;
      });

      //   获取二级归类!

      getTwoClassified(val.description).then((res) => {
        this.description = res.data;

        this.description = this.description.map((item) => {
          return { ...item, itemValue: Number(item.itemValue) };
        });
      });
    },
    //二级分类点击事件!

    // 获取当前选中部门的名称
    selectDepart(obj) {
      console.log("selectDepart---", obj);
      // this.formLabelAlign.pid = val.label;
    },
    //点击取消按钮弹框消失
    closeDialog() {
      this.$emit("dialogVisible", false);
    },
    //清除合伙人
    removePartner() {
      this.formInline.superiorPartner = null;
      this.formInline.teamPartnerStatus = "0";
      this.formInline.partnerName = null;
      this.formInline.partnerGrade = null;
    },
    // 获取角色数据
    bigStatus() {
      if (this.bigDataStatus === true) {
        this.formInline.bigDataStatus = 1;
      } else {
        this.formInline.bigDataStatus = 0;
      }
    },
    appStatus() {
      if (this.miniApp === true) {
        this.formInline.miniApp = 1;
      } else {
        this.formInline.miniApp = 0;
      }
    },
    minAppStatus() {
      if (this.recordMiniApp === true) {
        this.formInline.recordMiniApp = 1;
      } else {
        this.formInline.recordMiniApp = 0;
      }
    },
    channelPcStatus() {
      if (this.channelStatus === true) {
        this.formInline.channelStatus = 1;
      } else {
        this.formInline.channelStatus = 0;
      }
    },
    evaluateStatusButton() {
      if (this.evaluateStatus === true) {
        this.formInline.evaluateStatus = 1;
      } else {
        this.formInline.evaluateStatus = 0;
      }
    },
    async subDialog() {
      // this.$emit.handleNodeClick();
      try {
        // 等待表单校验成功
        await this.$refs.formInline.validate();
        this.formInline.roleIds = this.checkData;
        this.formInline.trenchPersonnel = this.bus.trenchPersonnel;
        if (this.formInline.teamPartnerStatus == "1") {
          if (this.formInline.partnerGrade == "") {
            this.$message.error("请选择合伙人");
            return false;
          }
        }
        if (this.formInline.id === "") {
          if (this.tbEmployeeUpdateRoleBtn == false) {
            this.$delete(this.formInline, "roleIds");
          }
          const { code, message } = await saveCompanyEmploy(
            JSON.stringify(this.formInline)
          );
          if (code === 200) {
            this.$message.success(message);
            this.$emit("dialogVisible", false);
            this.$emit("handleNodeClick");
          } else {
            this.$message.error(message);
          }
        } else {
          if (this.tbEmployeeUpdateRoleBtn == false) {
            this.$delete(this.formInline, "roleIds");
          }
          const { code, message } = await updateCompanyEmploy(
            JSON.stringify(this.formInline)
          );
          if (code === 200) {
            this.$message.success(message);
            this.$emit("dialogVisible", false);
            this.$emit("handleNodeClick");
          } else {
            this.$message.error(message);
          }
        }
      } catch (e) {
        return false;
      }
    },
  },
  mounted() {
    this.GetRandomNumber();
    this.getTableInform();
    this.getCompanyList();
    this.getGradeList();
  },
};
</script>

<style scoped type="less">
.box {
  text-align: left;
}
p {
  margin: 0 0 10px 20px;
}
.demo-form-inline .el-input {
  width: 240px;
  text-align: left;
}
.demo-form-inline .ts ::v-deep .el-input {
  width: unset;
}
.el-form-item__content {
  text-align: left;
}
.el-checkbox-group {
  text-align: left;
  margin-left: 30px;
}
.dialog-footer {
  display: block;
  text-align: center;
}
.el-form-item {
  margin-bottom: 10px;
}
.flex ::v-deep .el-form-item__content {
  display: flex;
}
.text.ts {
  padding: 0 30px;
}
.treeSelect ::v-deep.vue-treeselect__control {
  line-height: 30px;
  height: 33px;
}
.treeSelect ::v-deep.vue-treeselect__single-value,
.treeSelect ::v-deep.vue-treeselect__placeholder {
  line-height: 30px;
}
</style>
